package io.stream;

import java.io.*;

/**
 * @Package javaSE.io.stream
 * @Author shimmer
 * @Date 2020/5/28 10:02
 * @TODO 由于是二进制写入，可能存在乱码
 */
public class FileStreamTest01 {
    public static void main(String[] args) {
        try {
            //写入文件
            byte[] bWrite = {11, 21, 3, 20, 5};
            OutputStream os = new FileOutputStream("src\\main\\java\\javaSE\\io\\stream\\test01.txt");
            for (int i = 0; i < bWrite.length; i++) {
                os.write(bWrite[i]);
            }
            os.close();
            
            //读取文件
           InputStream is =  new FileInputStream("src\\main\\java\\javaSE\\io\\stream\\test01.txt");
            int size = is.available();
            for (int i = 0; i < size; i++) {
                System.out.println((char)is.read()+" ");
            }
            is.close();
        } catch (IOException e) {
            System.out.println("Exception");
        }
    }
}
